package god;

import java.util.Scanner;

public class J14Ex46CalendarV3Class {
	
	private static int cyear;
	private static int linecount = 0;
	private static int eCalendar;
	private static String result;
	
	public static int getCyear() { return cyear; }
	public void setCyear(int cyear) { this.cyear = cyear; }
	public static int geteCalendar() { return eCalendar; }
	public void seteCalendar(int eCalendar) { this.eCalendar = eCalendar; }
	
	public static Scanner makeScanner() {
		Scanner sc = new Scanner(System.in);
        return sc;
	}

	public void closeScanner( Scanner sc ) {
		sc.close();
	}
	
	public void inputCyear( Scanner sc ) {
		cyear = sc.nextInt();
	}
	
	public int eCalendar( int cyear ) {
		eCalendar +=  ( ( ( cyear-1 ) * 365 + ( cyear-1 ) / 100 + ( cyear-1 ) / 400 ) + 1 )  % 7;
		return eCalendar;
	}
	
	public static String printCalendar( int eCalendar ) {
		for ( int i = 1; i <= 12; ++i) {
			switch ( i ) {
			case 1 :
			    result = "\n\t\t\t" + ( cyear ) + "년 " + i + "월  \n" + "\t-------------------------------\n" + "\t일\t월\t화\t수\t목\t금\t토\n";
			    // 공백 처리
			    if ( eCalendar > 0 ) {
			    	for( int j = 0; j <= eCalendar; ++j) {
			        	result += "\t";
			        	++linecount;
			        }
			    }
			    // 날짜 출력
			    for ( int k = 1; k <= 31; ++k) {
			    	result += "\t" + k;
			        ++linecount;
			        if ( linecount % 7 == 0 ) { 
			        	result += "\n"; 
			        	linecount = 0;
			        	}
			        eCalendar = linecount;
			    }
			    System.out.println(result);
			    break;
			    
			case 2:
				System.out.println( eCalendar );
				result = "\n\t\t\t" + ( cyear ) + "년 " + i + "월  \n" + "\t-------------------------------\n" + "\t일\t월\t화\t수\t목\t금\t토\n";
			    // 공백 처리
			    if ( eCalendar > 0 ) {
			    	for( int j = 0; j <= eCalendar; ++j) {
			        	result += "\t";
			        	++linecount;
			        }
			    }
			    // 날짜 출력
			    for ( int k = 1; k <= 28; ++k) {
			    	result += "\t" + k;
			        ++linecount;
			        if ( linecount % 7 == 0 ) { 
			        	result += "\n";
			        	linecount = 0;
			        }
			        eCalendar = linecount;
			    }
			    System.out.println(result);
			    break;
			    
			case 3:
				System.out.println( eCalendar );
				result = "\n\t\t\t" + ( cyear ) + "년 " + i + "월  \n" + "\t-------------------------------\n" + "\t일\t월\t화\t수\t목\t금\t토\n";
			    // 공백 처리
			    if ( eCalendar > 0 ) {
			    	for( int j = 0; j <= eCalendar; ++j) {
			        	result += "\t";
			        	++linecount;
			        }
			    }
			    // 날짜 출력
			    for ( int k = 1; k <= 31; ++k) {
			    	result += "\t" + k;
			        ++linecount;
			        if ( linecount % 7 == 0 ) { 
			        	result += "\n";
			        	linecount = 0;
			        	}
			    }
			    System.out.println(result);
			    break;
			    
			case 4:
				System.out.println( eCalendar );
				result = "\n\t\t\t" + ( cyear ) + "년 " + i + "월  \n" + "\t-------------------------------\n" + "\t일\t월\t화\t수\t목\t금\t토\n";
			    // 공백 처리
			    if ( eCalendar > 0 ) {
			    	for( int j = 0; j <= eCalendar; ++j) {
			        	result += "\t";
			        	++linecount;
			        }
			    }
			    // 날짜 출력
			    for ( int k = 1; k <= 31; ++k) {
			    	result += "\t" + k;
			        ++linecount;
			        if ( linecount % 7 == 0 ) { 
			        	result += "\n";
			        	linecount = 0;
			        	}
			    }
			    System.out.println(result);
			    break;
			    
			case 5:
				System.out.println( eCalendar );
				result = "\n\t\t\t" + ( cyear ) + "년 " + i + "월  \n" + "\t-------------------------------\n" + "\t일\t월\t화\t수\t목\t금\t토\n";
			    // 공백 처리
			    if ( eCalendar > 0 ) {
			    	for( int j = 0; j <= eCalendar; ++j) {
			        	result += "\t";
			        	++linecount;
			        }
			    }
			    // 날짜 출력
			    for ( int k = 1; k <= 31; ++k) {
			    	result += "\t" + k;
			        ++linecount;
			        if ( linecount % 7 == 0 ) { 
			        	result += "\n";
			        	linecount = 0;
			        	}
			    }
			    System.out.println(result);
			    break;
			    
			case 6:
				System.out.println( eCalendar );
				result = "\n\t\t\t" + ( cyear ) + "년 " + i + "월  \n" + "\t-------------------------------\n" + "\t일\t월\t화\t수\t목\t금\t토\n";
			    // 공백 처리
			    if ( eCalendar > 0 ) {
			    	for( int j = 0; j <= eCalendar; ++j) {
			        	result += "\t";
			        	++linecount;
			        }
			    }
			    // 날짜 출력
			    for ( int k = 1; k <= 31; ++k) {
			    	result += "\t" + k;
			        ++linecount;
			        if ( linecount % 7 == 0 ) { 
			        	result += "\n";
			        	linecount = 0;
			        	}
			    }
			    System.out.println(result);
			    break;
			    
			case 7:
				System.out.println( eCalendar );
				result = "\n\t\t\t" + ( cyear ) + "년 " + i + "월  \n" + "\t-------------------------------\n" + "\t일\t월\t화\t수\t목\t금\t토\n";
			    // 공백 처리
			    if ( eCalendar > 0 ) {
			    	for( int j = 0; j <= eCalendar; ++j) {
			        	result += "\t";
			        	++linecount;
			        }
			    }
			    // 날짜 출력
			    for ( int k = 1; k <= 31; ++k) {
			    	result += "\t" + k;
			        ++linecount;
			        if ( linecount % 7 == 0 ) { 
			        	result += "\n";
			        	linecount = 0;
			        	}
			    }
			    System.out.println(result);
			    break;
			    
			case 8:
				System.out.println( eCalendar );
				result = "\n\t\t\t" + ( cyear ) + "년 " + i + "월  \n" + "\t-------------------------------\n" + "\t일\t월\t화\t수\t목\t금\t토\n";
			    // 공백 처리
			    if ( eCalendar > 0 ) {
			    	for( int j = 0; j <= eCalendar; ++j) {
			        	result += "\t";
			        	++linecount;
			        }
			    }
			    // 날짜 출력
			    for ( int k = 1; k <= 31; ++k) {
			    	result += "\t" + k;
			        ++linecount;
			        if ( linecount % 7 == 0 ) { 
			        	result += "\n";
			        	linecount = 0;
			        	}
			    }
			    System.out.println(result);
			    break;
			    
			case 9:
				System.out.println( eCalendar );
				result = "\n\t\t\t" + ( cyear ) + "년 " + i + "월  \n" + "\t-------------------------------\n" + "\t일\t월\t화\t수\t목\t금\t토\n";
			    // 공백 처리
			    if ( eCalendar > 0 ) {
			    	for( int j = 0; j <= eCalendar; ++j) {
			        	result += "\t";
			        	++linecount;
			        }
			    }
			    // 날짜 출력
			    for ( int k = 1; k <= 31; ++k) {
			    	result += "\t" + k;
			        ++linecount;
			        if ( linecount % 7 == 0 ) { 
			        	result += "\n";
			        	linecount = 0;
			        	}
			    }
			    System.out.println(result);
			    break;
			    
			case 10:
				System.out.println( eCalendar );
				result = "\n\t\t\t" + ( cyear ) + "년 " + i + "월  \n" + "\t-------------------------------\n" + "\t일\t월\t화\t수\t목\t금\t토\n";
			    // 공백 처리
			    if ( eCalendar > 0 ) {
			    	for( int j = 0; j <= eCalendar; ++j) {
			        	result += "\t";
			        	++linecount;
			        }
			    }
			    // 날짜 출력
			    for ( int k = 1; k <= 31; ++k) {
			    	result += "\t" + k;
			        ++linecount;
			        if ( linecount % 7 == 0 ) { 
			        	result += "\n";
			        	linecount = 0;
			        	}
			    }
			    System.out.println(result);
			    break;
			    
			case 11:
				System.out.println( eCalendar );
				result = "\n\t\t\t" + ( cyear ) + "년 " + i + "월  \n" + "\t-------------------------------\n" + "\t일\t월\t화\t수\t목\t금\t토\n";
			    // 공백 처리
			    if ( eCalendar > 0 ) {
			    	for( int j = 0; j <= eCalendar; ++j) {
			        	result += "\t";
			        	++linecount;
			        }
			    }
			    // 날짜 출력
			    for ( int k = 1; k <= 31; ++k) {
			    	result += "\t" + k;
			        ++linecount;
			        if ( linecount % 7 == 0 ) { 
			        	result += "\n";
			        	linecount = 0;
			        	}
			    }
			    System.out.println(result);
			    break;
			    
			case 12:
				System.out.println( eCalendar );
				result = "\n\t\t\t" + ( cyear ) + "년 " + i + "월  \n" + "\t-------------------------------\n" + "\t일\t월\t화\t수\t목\t금\t토\n";
			    // 공백 처리
			    if ( eCalendar > 0 ) {
			    	for( int j = 0; j <= eCalendar; ++j) {
			        	result += "\t";
			        	++linecount;
			        }
			    }
			    // 날짜 출력
			    for ( int k = 1; k <= 31; ++k) {
			    	result += "\t" + k;
			        ++linecount;
			        if ( linecount % 7 == 0 ) { 
			        	result += "\n";
			        	linecount = 0;
			        	}
			    }
			    System.out.println(result);
			    break;
			}
		}
		return result;
	}
}
